﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
using AutoMapper;
using Logica;
using Entidades;


namespace JusTime_TransValle
{
    /// <summary>
    /// Descripción breve de ServiciosJusTime
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // Para permitir que se llame a este servicio web desde un script, usando ASP.NET AJAX, quite la marca de comentario de la línea siguiente. 
    [System.Web.Script.Services.ScriptService]
    public class ServiciosJusTime : System.Web.Services.WebService
    {
        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public string LoguearPlataforma(string usuario, string cedula)
        {
            usuPlataformaBLL usu = new usuPlataformaBLL();
            return usu.LoguearPlataforma(usuario,cedula);            
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public BusDTO getBus(string plac)
        {
            BusBLL bus = new BusBLL();
            return bus.getBus(plac);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public RutaDTO getRutaBus(string plac)
        {
            BusBLL rutaBus = new BusBLL();
            return rutaBus.getRutaBus(plac);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public RutaDTO getRuta(string NomRuta)
        {
            RutaBLL r = new RutaBLL();
            return r.getRuta(NomRuta);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public List<MovBusDTO> ObtenerCoorenadas(string NomRuta)
        {
            BusBLL CoorBus = new BusBLL();
            return CoorBus.ObtenerCoordenadas(NomRuta);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public List<RutaDTO> getRutas()
        {
            RutaBLL r = new RutaBLL();
            return r.getRutas();
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public List<BusDTO> ObtenerTodosBuses()
        {
            BusBLL tBuses = new BusBLL();
            return tBuses.ObtenerTodosBuses();
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public string NuevoBus(string Placa, string Color, string Modelo, string NumeroMotor, string Password)
        {
            BusBLL bus = new BusBLL();
            return bus.NuevoBus(Placa, Color, Modelo, NumeroMotor, Password);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public string EliminarBus(string Placa)
        {
            BusBLL bus = new BusBLL();
            return bus.EliminarBus(Placa);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public string LoguearBus(string plac, string pass)
        {
            BusBLL bus = new BusBLL();
            return bus.LoguearBus(plac, pass);
        }
    
        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public void EnviarCoordenadas(string plac, string latitud, string longitud, string Velocidad, string Punto)
        {
            BusBLL bus = new BusBLL();
            bus.EnviarCoordenadas(plac, latitud, longitud, Velocidad, Punto);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public string EnviarRuta(RutaDTO mruta)
        {
            RutaBLL rut = new RutaBLL();
            return rut.NuevaRuta(mruta);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public string AsigPuntosRuta(PuntoDTO Punto, string NomRuta, string item)
        {
            RutaBLL rut = new RutaBLL();
            return rut.AsigPuntosRuta(Punto, NomRuta, int.Parse(item));
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public List<CoordenadasRutaDTO> getCoordenadasRuta(string NomRuta)
        {
            RutaBLL r = new RutaBLL();
            return r.GetCoordenadasRuta(NomRuta);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public string EliminarRuta(string NomRuta)
        {
            RutaBLL r = new RutaBLL();
            return r.EliminarRuta(NomRuta);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public string AsignarBusARuta(string Conductor, string Placa, string NomRuta)
        {
            ControlBusesBLL ctrlB = new ControlBusesBLL();
            return ctrlB.AsignarBusARuta(Conductor,Placa,NomRuta);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public List<AsignacionDTO> getAsignaciones()
        {
            ControlBusesBLL CtrlBuses = new ControlBusesBLL();
            return CtrlBuses.getAsignaciones();
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public List<PuntoHistorialDTO> ObtenerHistorial(DateTime Fecha, string Placa)
        {
            HistorialMovimientosBLL ObjHist = new HistorialMovimientosBLL();
            return ObjHist.ObtenerHistorial(Fecha, Placa);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public List<ReporteBusDiaDTO> ReporteRutaDia(string Ruta, DateTime Fecha)
        {
            ReportesBLL Report = new ReportesBLL();
            return Report.ReporteRutaDia(Ruta, Fecha);
        }

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public List<ReporteRecorridoDTO> ReporteBusRecorridos(DateTime Fecha, string Placa)
        {
            ReportesBLL reporte = new ReportesBLL();
            return reporte.ReporteBusRecorridos(Fecha, Placa);
        }
    }
}
